package common

import (
	"fmt"
	"go-init/dao"
	"go-init/lib/ctx"
	"go-init/lib/log"
	"go-init/lib/tool"
)

type COMMON struct{}

// Delete
// @tags common
// @Summary 删除通用接口
// @Description 删除通用接口
// @Accept  x-www-form-urlencoded
// @Produce  json
// @Param table body string true "表名"
// @Param id body string true "主键属性值"
// @Success 200 {array} ctx.R "结果"
// @Failure 400 {object} ctx.HTTPError
// @Router /api/common/delete [post]
func (u *COMMON) Delete(c *ctx.Context) {
	table := c.PostForm("table")
	id := c.PostForm("id")
	_, err := dao.Exec(fmt.Sprintf("update %s set is_delete=1,modify_time=? where id=?", table), tool.GetNows(), id)
	if c.HandlerError(err) {
		log.Error(err)
		return
	}
	c.JSON(200, ctx.R{Status: 1, Data: id})
}
